package Org.csmzxy.class2333;

class Student2 {
    static String name;  //静态变量
    int age;  //实例变量
    public Student2() {
        System.out.println("执行构造方法");
    }
    {
        System.out.println("执行实例代码块");
        age = 18;
    }
    static {
        System.out.println("执行静态代码块");
        name = "张三";
    }
}
public class Example12 {
    public static void main(String[] args) {
        Student2 s1 = new Student2();
        System.out.println("name = " + Student2.name + ",age = " + s1.age);
        Student2 s2 = new Student2();
        System.out.println("name = " + Student2.name + ",age = " + s2.age);
        Student2 s3 = new Student2();
        System.out.println("name = " + Student2.name + ",age = " + s3.age);
    }
}
